#include <stdio.h>
#include <algorithm>

#define N 100

using namespace std;

int n,a[N],b[N];
int cmp(int a,int b)
{
	return a>b;
}

int minsum(int a[],int m)
{
	int sum=0;
	for(int i=0;i<n;i++)
	{
		b[i]=a[i];
	}
	while(m>1)
	{
		sort(b,b+m);
		b[0]=b[0]+b[1];
		sum+=b[0]-1;
		b[1] = b[m-1];
		m--;
	}
	return sum;
} 


int maxsum(int a[],int m)
{
	int sum=0;
	for(int i=0;i<n;i++)
	{
		b[i]=a[i];
	}
	while(m>1)
	{
		sort(b,b+m,cmp);
		b[0]=b[0]+b[1];
		sum+=b[0]-1;
		b[1] = b[m-1];
		m--;
	}
	return sum;
} 

int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	
	printf("min:%d\n",minsum(a,n));
	printf("max:%d\n",maxsum(a,n));
}